import { customForm } from '@/components/ProForm/interface/index';
import { ProTableValue } from '@/interface/public';

export function useAddForm(proTableBox: ProTableValue) {
  let addForm = reactive<customForm>({
    form: {
      value: ''
    },
    title: '',
    visible: false,
    transitionArr: [],
    options: [
      {
        type: 'input',
        label: 'ID',
        prop: 'id',
        hide: true
      },
      {
        type: 'input',
        hide: false,
        prop: 'setValue',
        label: '值'
      },
      {
        type: 'input',
        hide: false,
        prop: 'showOrder',
        label: '排序',
        attrs: {
          type: 'number'
        }
      },
      {
        type: 'input',
        hide: false,
        prop: 'remark',
        label: '备注'
      }
    ]
  });

  const saveAddForm = async form => {
    await setSave(form);
    addForm.visible = false;
    elMessage();
    proTableBox.value?.getTableList();
  };
  return { addForm, saveAddForm };
}
